Imports System.Windows.Forms

Public Class CmdParams
    Private requiredVal As Boolean = True
    Private isBoolVal As Boolean = False

    Private Sub CmdParams_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txtValue.Focus()
    End Sub

    Property Required() As Boolean
        Get
            Return requiredVal
        End Get
        Set(ByVal value As Boolean)
            requiredVal = value
        End Set
    End Property

    Property IsBool() As Boolean
        Get
            Return isBoolVal
        End Get
        Set(ByVal value As Boolean)
            isBoolVal = value
            If value = True Then
                txtValue.Visible = False
                cbValue.Location = txtValue.Location
                cbValue.Size = txtValue.Size
                cbValue.Visible = True
            End If
        End Set
    End Property

    Property ParamValue() As String
        Get
            If IsBool() Then Return cbValue.Text Else Return txtValue.Text
        End Get
        Set(ByVal value As String)
            If IsBool() Then cbValue.Text = value Else txtValue.Text = value
        End Set
    End Property

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        If Required And ((txtValue.Text.Length = 0 And IsBool = False) Or (cbValue.Text.Length = 0 And IsBool = True)) Then
            MessageBox.Show("A parameter value is required.", "", MessageBoxButtons.OK, MessageBoxIcon.Error)
            If IsBool = False Then txtValue.Focus() Else cbValue.Focus()
            Return
        End If
        Close()
    End Sub
End Class